<template>
  <div>
    <el-card>
      <p>纪承</p>
      <!-- 提示 -->
      <el-alert
        type="info"
        show-icon
        :closable="false"
        :title="'数据一共' + total + '条'"
      >
      </el-alert>

      <el-table :data="createApiList" style="width: 100%">
        <el-table-column prop="type" label="操作类型"> </el-table-column>
        <el-table-column prop="author" label="操作人"> </el-table-column>
        <el-table-column prop="title" label="执行结果"> </el-table-column>
        <el-table-column prop="display_time" label="操作时间">
          <template slot-scope="{ row }">{{
            row.display_time | parseTime
          }}</template>
        </el-table-column>
        <el-table-column prop="forecast" label="描述"> </el-table-column>
      </el-table>
      <!-- 分页 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="queryInfo.page"
        :page-sizes="[5, 10, 20, 50]"
        :page-size="queryInfo.pagesize"
        layout="sizes, prev, pager, next, jumper"
        :total="total"
        background
      >
      </el-pagination>
    </el-card>
  </div>
</template>

<script>
import { list as createApiList } from '../../api/example/table'
export default {
  data () {
    return {
      createApiList: [],
      total: 0,
      queryInfo: {
        keyword: null,
        page: 1,
        pagesize: 5,
        state: null
      }
    }
  },

  created () {
    this.getcreateApiList()
  },

  methods: {
    async getcreateApiList () {
      try {
        const { data } = await createApiList(this.queryInfo)
        // console.log(data)
        this.createApiList = data.items
        this.total = data.total
      } catch (err) {
        console.log(err)
      }
    },
    // 改变每页条数
    handleSizeChange (val) {
      console.log(val)
      this.queryInfo.pagesize = val
      this.getcreateApiList()
    },
    // 切换当前页
    handleCurrentChange (val) {
      console.log(val)
      this.queryInfo.page = val
      this.getcreateApiList()
    }
  }
}
</script>

<style scoped lang='less'>
</style>
